#!/sbin/openrc-run

supervisor=supervise-daemon

command="/usr/bin/octoprint"
command_args="serve --basedir /etc/octoprint"
command_user="octoprint:octoprint"
directory="/var/lib/octoprint"

depend() {
	need net
	after firewall
}

start_pre() {
	checkpath -d -m 755 -o "octoprint:octoprint" /etc/octoprint
	checkpath -d -m 755 -o "octoprint:octoprint" /run/octoprint
	checkpath -d -m 755 -o "octoprint:octoprint" /run/octoprint/watched
	checkpath -d -m 755 -o "octoprint:octoprint" /var/lib/octoprint
	checkpath -d -m 755 -o "octoprint:octoprint" /var/log/octoprint

	# contains secrets for api, cookies
	checkpath -f -m 640 -o "octoprint:octoprint" /etc/octoprint/config.yaml
}
